<template>
	<div>

		<el-row :gutter="10">
			<el-col :span="5">
				<el-input v-model="search.customerName" placeholder="请输入要查询的姓名"></el-input>
			</el-col>
			<el-col :span="6">
				<el-button type="primary" icon="el-icon-search" @click="searchData()">搜索</el-button>
				<el-button type="primary" icon="el-icon-circle-plus-outline" plain @click="add()">添加</el-button>
			</el-col>
		</el-row>
		<el-table :data="result.tableData" style="width: 100%">
			<el-table-column label="序号" prop="outgoingId" width="48px"></el-table-column>

			<el-table-column label="客户姓名" prop="customerName" width="80px"></el-table-column>

			<el-table-column label="客户编号" prop="customerId" width="80px"></el-table-column>

			<el-table-column label="性别" prop="customerGender" width="48px"></el-table-column>

			<el-table-column label="年龄" prop="customerAge" width="48px"></el-table-column>

			<el-table-column label="档案编号" prop="recordId" width="150px"></el-table-column>

			<el-table-column label="外出原因	" prop="outgoingCause" width="110px"></el-table-column>

			<el-table-column label="外出时间	" prop="outgoingDate" width="160px"></el-table-column>

			<el-table-column label="预计回来时间	" prop="expectedReturnDate" width="160px"></el-table-column>

			<el-table-column label="实际回来时间	" prop="actualReturnDate" width="160px"></el-table-column>

			<el-table-column label="陪同人	" prop="accompaniedPerson" width="80px"></el-table-column>

			<el-table-column label="与老人关系" prop="relation" width="120px"></el-table-column>

			<el-table-column label="陪同人电话" prop="accTelephone" width="120px"></el-table-column>

			<el-table-column label="审批状态	" prop="status" width="80px"></el-table-column>

			<el-table-column label="审批人	" prop="auditPerson" width="100px"></el-table-column>

			<el-table-column label="审批时间	" prop="auditDate" width="120px"></el-table-column>



			<!-- <el-table-column label="是否删除	" prop="isDeleted" width="80px"></el-table-column> -->

			<el-table-column label="操作" width="150px">
				<template slot-scope="scope">
					<el-button size="mini" @click="handleEdit(scope.row.outgoingId)">编辑</el-button>
					<el-button size="mini" type="danger" @click="handleDelete(scope.row.outgoingId)">删除</el-button>
				</template>
			</el-table-column>
		</el-table>

		<el-pagination style="margin-top:20px;" background layout="prev, pager, next" :total="result.total"
			:current-page.sync="query.current" :page-size="query.size" @current-change="getData()">
		</el-pagination>

		<el-dialog :title="title" :visible.sync="show">

			<OutAdd :show.sync="show" @getData="getData" :editid="editid" :key="showNum"></OutAdd>

		</el-dialog>
	</div>
</template>
<script>
	import axios from '@/utils/axiosutils.js';
	import OutAdd from './add.vue';
	export default {
		data() {
			return {
				search: {
					customerName: ''
				},
				query: {
					customerName: '',
					current: 1,
					size: 10
				},
				result: {
					tableData: [],
					pages: 0
				},
				showNum: 0,
				show: false,
				editid: null,
				title: ''
			};
		},
		components: {
			OutAdd
		},
		created() {
			this.getData();
		},
		methods: {
			getData() {
				axios.get(
					'/outgoing/list',
					resp => {
						console.log(resp.obj.records);
						let page = resp.obj;
						this.result.tableData = page.records
						this.result.total = page.total;
					},
					this.query
				);
			},
			searchData() {
				this.query.customerName = this.search.customerName
				this.query.current = 1
				this.getData()
			},
			add() {
				this.showNum++;
				this.title = '添加用户'
				this.editid = null
				this.show = true
			},
			handleEdit(outgoingId) {
				this.showNum++;
				this.title = '修改用户'
				this.editid = outgoingId
				this.show = true
			},
			handleDelete(outgoingId) {
				axios.del('/outgoing/del', response => {
					this.getData()
				}, {
					outgoingId: outgoingId
				})
			}
		}
	};
</script>

<style>
	.el-row {
		height: 50px;
	}

	.el-main {
		background-color: #e9eef3;
		color: #333;
		line-height: 20px !important;
	}
</style>
